from collections import deque


class PlaceOneParse(object):

    def __init__(self):
        self.data_info_dict: dict = {}
        # 正在处理的index 和 line
        self.now_deal_index_line = deque(maxlen=5)

    def run_parse(self, one_text):
        self.data_info_dict = {}
        lists_v = one_text.split('\u0009')  # \u0009 是制表符空格 tab
        if len(lists_v) != 9:
            raise Exception(f"长度错误,按照tab分割后目前的字段量为:{len(lists_v)},约定的分割后应该为9")
        self.data_info_dict["place_raw"] = lists_v[0]  # 原始字符串
        self.data_info_dict["place_name"] = lists_v[1]  # 地名
        self.data_info_dict["place_variant_name"] = lists_v[2].split('\u3000')  # 輔名
        self.data_info_dict["place_type"] = lists_v[3]  # 属性
        self.data_info_dict["place_note"] = lists_v[4]  # 注释
        self.data_info_dict["location"] = lists_v[5]  # 位置
        self.data_info_dict["longitude"] = lists_v[6]  # 精度
        self.data_info_dict["latitude"] = lists_v[7]  # 维度
        self.data_info_dict["place_source"] = [i.strip() for i in lists_v[8].split('$') if i]
        return self.data_info_dict
